<?php
declare(strict_types=1);
namespace App\Service\Community\Users;
use App\Models\User;
class UsersUpdate implements UsersUpdateInterface {

    public function user_store($request,$user,$uploader):bool{
        $data = [];
        $data['name'] = $request->name;
        $data['introduction']=$request->introduction;
        if ($request->password) {
            $data['password'] = bcrypt($request->password);
        }
        if ($request->avatar) {
            $result = $uploader->save($request->avatar, 'avatars', $user->id);
            if ($result) {
                $data['avatar'] = $result['path'];
            }
        }
        return $user->update($data);
    }
}
